package org.example.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class AspectConfiguration {

    private final Logger logger = LoggerFactory.getLogger(AspectConfiguration.class);

    @Pointcut("execution(public * org.example.service.*.*(..))")
    public void pointcut() {
    }

//    @Before("pointcut()")
//    public void before() {
//        logger.info("---------前置增强---------");
//    }

    @Around("pointcut()")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        logger.info("---------前置通知---------");
        Object proceed = joinPoint.proceed();
        logger.info("---------后置通知---------");
        return proceed;
    }


}
